package com.exhibition.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.exhibition.service.ITbExhInfoService;
import com.exhibition.service.ITbExhUnitService;
import com.exhibition.service.ITbHostService;
import com.exhibition.service.ITbSampleInfoService;
import com.exhibition.service.ITbSampleTypeService;

@Controller
public class AccountController {
	 
	@Autowired
	ITbHostService tbHostService;
	@Autowired
	ITbExhInfoService tbExhInfoService;
	@Autowired
	ITbExhUnitService tbExhUnitService;
	@Autowired
	ITbSampleTypeService tbSampleTypeService;
	@Autowired
	ITbSampleInfoService tbSampleInfoService;
	
	/**统1
	 * @param request
	 * @return
	 */
	@RequestMapping("admin/accountOne.do")	
	public ModelAndView one(HttpServletRequest request){
		ModelAndView mav=new ModelAndView("./account/account_one.jsp");
		String title="[";
		String data="[";
		List<Map<String,Object>> list=tbHostService.getList(new HashMap<String, Object>());
		for (Map<String, Object> map : list) {
			title+="'"+map.get("host_name")+"',";
			Map<String,Object> param=new HashMap<String, Object>();
			param.put("unit_id", map.get("unit_id"));
			Integer count= tbExhInfoService.getList(param).size();
			data+=count+",";
		}
		title=title.substring(0, title.length()-1);
		data=data.substring(0, data.length()-1);
		title+="]";
		data+="]";
		mav.addObject("title",title);
		mav.addObject("data",data);
		return mav;
	}
	/**统2
	 * @param request
	 * @return
	 */
	@RequestMapping("admin/accountTwo.do")	
	public ModelAndView Two(HttpServletRequest request){
		ModelAndView mav=new ModelAndView("./account/account_two.jsp");
		String title="[";
		String data="[";
		List<Map<String,Object>> list=tbExhInfoService.getList(new HashMap<String, Object>());
		for (Map<String, Object> map : list) {
			title+="'"+map.get("ehi_name")+"',";
			Map<String,Object> param=new HashMap<String, Object>();
			param.put("exh_id", map.get("exh_id"));
			Integer count= tbExhUnitService.getList(param).size();
			data+=count+",";
		}
		title=title.substring(0, title.length()-1);
		data=data.substring(0, data.length()-1);
		title+="]";
		data+="]";
		mav.addObject("title",title);
		mav.addObject("data",data);
		return mav;
	}
	/**统1
	 * @param request
	 * @return
	 */
	@RequestMapping("admin/accountThree.do")	
	public ModelAndView Three(HttpServletRequest request){
		ModelAndView mav=new ModelAndView("./account/account_three.jsp");
		String title="[";
		String data="[";
		List<Map<String,Object>> list=tbSampleTypeService.getList(new HashMap<String, Object>());
		for (Map<String, Object> map : list) {
			title+="'"+map.get("type_name")+"',";
			Map<String,Object> param=new HashMap<String, Object>();
			param.put("type_id", map.get("type_id"));
			Integer count= tbSampleInfoService.getList(param).size();
			data+=count+",";
		}
		title=title.substring(0, title.length()-1);
		data=data.substring(0, data.length()-1);
		title+="]";
		data+="]";
		mav.addObject("title",title);
		mav.addObject("data",data);
		return mav;
	}
}
